{* Affiliate program settings and info *}
<script language="javascript" type="text/javascript">
<!--
window.reloadURL = '{$REQUEST_URI}';
//-->
</script>
{if $safemode}<div class="error_msg_f">{$smarty.const.ADMIN_SAFEMODE_WARNING}</div>{/if}
<table>
<tr>
<td nowrap="nowrap">

{* recruited customers table *}

<b style="font-size:110%">{$smarty.const.STRING_AFFILIATE_CUSTOMERS}</b>
<br /><br />
{$smarty.const.STRING_AFFILIATE_CUSTOMERS}: {$RecruitedCustomersNumber}
<form action="{$REQUEST_URI}" method="POST" name="form_cancel_customer" style="display:none;">
<input name="fACTION" value="CANCEL_CUSTOMER" type="hidden" />
<input name="fREDIRECT" value="{$REQUEST_URI}" type="hidden" />
<input name="CUSTOMER[customerID]" value="" type="hidden" />
</form>
{if $RecruitedCustomersNumber}
<table width="100%" border="0" cellpadding="5" cellspacing="1" bgcolor="#56AFD6">
	<tr bgcolor="#BEDDDB">
		<td width="97%">
			{$smarty.const.ADMIN_CUSTOMER_LOGIN}
		</td>
		<td width="1%" nowrap="nowrap">{$smarty.const.STR_ACTSTATE}</td>
		<td width="1%" nowrap="nowrap">
			{$smarty.const.ADMIN_REGISTRATION_TIME}
		</td>
		<td width="1%">&nbsp;</td>
	</tr>

	{foreach from=$RecruitedCustomers item=_Customer}
		
		<tr bgcolor="#FFFFFF">
			<td>
				<a href="{''|set_query}?dpt=custord&sub=custlist&customer_details=contact_info&customerID={$_Customer.customerID}">{$_Customer.Login}</a>
			</td>
			<td align="center">
				{if $_Customer.ActivationCode}
					{$smarty.const.STR_NOTACTIVATED}
				{else}
					{$smarty.const.STR_ACTIVATED}
				{/if}
			</td>
			<td align="center">
				{$_Customer.reg_datetime}
			</td>
			<td><a href="javascript:void(0)" onclick="
					if(!confirm('{$smarty.const.STRING_LE_CONFIRM}'))return false;
					document.form_cancel_customer.elements['CUSTOMER[customerID]'].value = {$_Customer.customerID};
					document.form_cancel_customer.submit();
					return false;
					" title="{$smarty.const.AFFP_REMOVE_USER}"><img src="./images/remove.jpg" border="0" alt="{$smarty.const.AFFP_REMOVE_USER}" /></a></td>
		</tr>
	{/foreach}

</table>

{/if}{* if $RecruitedCustomersNumber *}

{* calendar form *}

<hr />
<b style="font-size:110%">{$smarty.const.AFFP_COMMISSION_PAYMENTS}</b>

<br /><br />
<b>{$smarty.const.STRING_CALENDAR}</b>
<form method="POST" action="{$REQUEST_URI}">
{if $Error_DateFormat}
<div class="error_msg_f">{$smarty.const.AFFP_MSG_ERROR_DATE_FORMAT}</div>
{/if}
{$smarty.const.STRING_FROM}: <input type="text" name="from" value="{$from}" size="12" /> {$smarty.const.STRING_TILL}: <input name="till" value="{$till}" type="text" size="12" /> <input value="{$smarty.const.VIEW_BUTTON}" type="submit" />
</form>
{if !$show_tables}
{$smarty.const.MSG_PERIOD_ISNT_SPECIFIED}
{/if}

<hr />

{* commissions table *}

{if $show_tables}
<b>{$smarty.const.AFFP_STRING_CUSTOMER_COMMISSIONS} ({$smarty.const.STRING_FROM} {$from} {$smarty.const.STRING_TILL} {$till})</b> 

{if $delete_commission}<div class="ok_msg_f">{$smarty.const.AFFP_MSG_COMMISSION_DELETED}</div>{/if}
{/if}{* if $show_tables *}

<p><a href="?dpt=custord&sub=affiliate&edCustomerID={$edCustomerID}#new_commission_anchor">{$smarty.const.AFFP_SUBMIT_NEW_COMMISSION}</a></p>

{if $CommissionsNumber and $show_tables}
	<form action="{$REQUEST_URI}" method="POST" name="form_delete_commission" style="display:none;">
	<input name="fACTION" value="DELETE_COMMISSION" type="hidden" />
	<input name="fREDIRECT" value="{$REQUEST_URI}" type="hidden" />
	<input name="COMMISSION[cID]" value="" type="hidden" />
	</form>

	<table width="100%" border="0" cellpadding="5" cellspacing="1" bgcolor="#56AFD6">
		<tr bgcolor="#BEDDDB">
			<td>
				<table>
					<tr>
						<td rowspan="2">ID</td>
						<td><a href="{'OrderFieldC=cID&OrderDivC=ASC'|set_query:$REQUEST_URI}"><img SRC="./images/arrow_up.gif" border=0></a> </td>
					</tr>
					<tr>
						<td><a href="{'OrderFieldC=cID&OrderDivC=DESC'|set_query:$REQUEST_URI}"><img SRC="./images/arrow_down.gif" border=0></a></td>
					</tr>
				</table>
			</td>
			<td>
				<table><tr>
						<td rowspan="2">{$smarty.const.ADMIN_CURRENT_DATE}</td>
						<td><a href="{'OrderFieldC=xDateTime&OrderDivC=ASC'|set_query:$REQUEST_URI}"><img SRC="./images/arrow_up.gif" border=0></a> </td>
					</tr><tr>
						<td><a href="{'OrderFieldC=xDateTime&OrderDivC=DESC'|set_query:$REQUEST_URI}"><img SRC="./images/arrow_down.gif" border=0></a></td>
					</tr></table>
			</td>
			<td>
				<table>
					<tr>
						<td rowspan="2">{$smarty.const.STRING_DESCRIPTION}</td>
						<td><a href="{'OrderFieldC=Description&OrderDivC=ASC'|set_query:$REQUEST_URI}"><img SRC="./images/arrow_up.gif" border=0></a> </td>
					</tr>
					<tr>
						<td><a href="{'OrderFieldC=Description&OrderDivC=DESC'|set_query:$REQUEST_URI}"><img SRC="./images/arrow_down.gif" border=0></a></td>
					</tr>
				</table>
			</td>
			<td align="center">
				<table align="center">
					<tr>
						<td rowspan="2">{$smarty.const.STRING_SUM}</td>
						<td><a href="{'OrderFieldC=Amount&OrderDivC=ASC'|set_query:$REQUEST_URI}"><img SRC="./images/arrow_up.gif" border=0></a> </td>
					</tr>
					<tr>
						<td><a href="{'OrderFieldC=Amount&OrderDivC=DESC'|set_query:$REQUEST_URI}"><img SRC="./images/arrow_down.gif" border=0></a></td>
					</tr>
				</table>
			</td>
			<td width="1%">&nbsp;</td>
			<td width="1%">&nbsp;</td>
		</tr>
		{foreach from=$Commissions item=_Commission}
			{assign_array var="TotalCommissionsAmount" index=$_Commission.CurrencyISO3 value=$TotalCommissionsAmount[$_Commission.CurrencyISO3]+$_Commission.Amount}
		<tr bgcolor="#FFFFFF">
			<td>C-{$_Commission.cID}</td>
			<td>{$_Commission.xDateTime}</td>
			<td>{$_Commission.Description}</td>
			<td align="right" nowrap="nowrap">{$_Commission.Amount} {$_Commission.CurrencyISO3}</td>
			<td><a href="javascript:open_window('{"sub_page=edit_commission&cID=`$_Commission.cID`"|set_query}',500,400);">{$smarty.const.EDIT_BUTTON}</a></td>
			<td><a href="javascript:void(0)" onclick="
				if(!confirm('{$smarty.const.STRING_LE_CONFIRM}'))return false;
				document.form_delete_commission.elements['COMMISSION[cID]'].value = {$_Commission.cID};
				document.form_delete_commission.submit();
				return false;
				" title="{$smarty.const.DELETE_BUTTON}"><img src="./images/remove.jpg" border=0 alt="{$smarty.const.DELETE_BUTTON}" /></a></td>
		</tr>
		{/foreach}
		<tr>
			<td colspan="1" valign="top">
				{$smarty.const.STRING_SUM}
			</td>
			<td colspan="5" align="right">
				<table align="right">
				{foreach from=$TotalCommissionsAmount key=_key item=_total}
					<tr><td align="right">{$_total|string_format:"%.2f"}</td><td>{$_key}</td></tr>
				{/foreach}
				</table>
			</td>
		</tr>
	</table>
{elseif $show_tables}
	<br /><br />{$smarty.const.AFFP_MSG_NOCOMMISISONS_FOUND}
{/if}{* if $CommissionsNumber and show_tables *}

{* payments table *}

<hr />

{if $show_tables}
<b>{$smarty.const.AFFP_STRING_PAYMENTS_TO_CUSTOMERS} ({$smarty.const.STRING_FROM} {$from} {$smarty.const.STRING_TILL} {$till})</b>

{if $delete_payment}<div class="ok_msg_f">{$smarty.const.AFFP_MSG_PAYMENT_DELETED}</div>{/if}
{/if}{* if $show_tables *}

<p><a href="?dpt=custord&sub=affiliate&edCustomerID={$edCustomerID}#new_payment_anchor">{$smarty.const.AFFP_SUBMIT_NEW_PAYMENT}</a></p>

{if $PaymentsNumber and $show_tables}
	<form action="{$REQUEST_URI}" method="POST" name="form_delete_payment" style="display:none;">
	<input name="fACTION" value="DELETE_PAYMENT" type="hidden" />
	<input name="fREDIRECT" value="{$REQUEST_URI}" type="hidden" />
	<input name="PAYMENT[pID]" value="" type="hidden" />
	</form>
	
	<table width="100%" border="0" cellpadding="5" cellspacing="1" bgcolor="#56AFD6">
		<tr bgcolor="#BEDDDB">
			<td>
				<table>
					<tr>
						<td rowspan="2">ID</td>
						<td><a href="{'OrderField=pID&OrderDiv=ASC'|set_query:$REQUEST_URI}"><img SRC="./images/arrow_up.gif" border=0></a> </td>
					</tr>
					<tr>
						<td><a href="{'OrderField=pID&OrderDiv=DESC'|set_query:$REQUEST_URI}"><img SRC="./images/arrow_down.gif" border=0></a></td>
					</tr>
				</table>
			</td>
			<td>
				<table>
					<tr>
						<td rowspan="2">{$smarty.const.ADMIN_CURRENT_DATE}</td>
						<td><a href="{'OrderField=xDate&OrderDiv=ASC'|set_query:$REQUEST_URI}"><img SRC="./images/arrow_up.gif" border=0></a> </td>
					</tr>
					<tr>
						<td><a href="{'OrderField=xDate&OrderDiv=DESC'|set_query:$REQUEST_URI}"><img SRC="./images/arrow_down.gif" border=0></a></td>
					</tr>
				</table>
			</td>
			<td>
				<table>
					<tr>
						<td rowspan="2">{$smarty.const.STRING_DESCRIPTION}</td>
						<td><a href="{'OrderField=Description&OrderDiv=ASC'|set_query:$REQUEST_URI}"><img SRC="./images/arrow_up.gif" border=0></a> </td>
					</tr>
					<tr>
						<td><a href="{'OrderField=Description&OrderDiv=DESC'|set_query:$REQUEST_URI}"><img SRC="./images/arrow_down.gif" border=0></a></td>
					</tr>
				</table>
			</td>
			<td align="center">
				<table align="center">
					<tr>
						<td rowspan="2">{$smarty.const.STRING_SUM}</td>
						<td><a href="{'OrderField=Amount&OrderDiv=ASC'|set_query:$REQUEST_URI}"><img SRC="./images/arrow_up.gif" border=0></a> </td>
					</tr>
					<tr>
						<td><a href="{'OrderField=Amount&OrderDiv=DESC'|set_query:$REQUEST_URI}"><img SRC="./images/arrow_down.gif" border=0></a></td>
					</tr>
				</table>
			</td>
			<td width="1%">&nbsp;</td>
			<td width="1%">&nbsp;</td>
		</tr>
		{foreach from=$Payments item=_Payment}
			{assign_array var="TotalPaymentsAmount" index=$_Payment.CurrencyISO3 value=$TotalPaymentsAmount[$_Payment.CurrencyISO3]+$_Payment.Amount}
		<tr bgcolor="#FFFFFF">
			<td>P-{$_Payment.pID}</td>
			<td>{$_Payment.xDate}</td>
			<td>{$_Payment.Description}</td>
			<td nowrap="nowrap" align="right">{$_Payment.Amount} {$_Payment.CurrencyISO3}</td>
			<td><a href="javascript:open_window('{"sub_page=edit_payment&pID=`$_Payment.pID`"|set_query}',500,400);">{$smarty.const.EDIT_BUTTON}</a></td>
			<td><a href="javascript:void(0)" onclick="
				if(!confirm('{$smarty.const.STRING_LE_CONFIRM}'))return false;
				document.form_delete_payment.elements['PAYMENT[pID]'].value = {$_Payment.pID};
				document.form_delete_payment.submit();
				return false;
				" title="{$smarty.const.DELETE_BUTTON}"><img src="./images/remove.jpg" border=0 alt="{$smarty.const.DELETE_BUTTON}" /></a></td>
		</tr>
		{/foreach}
		<tr>
			<td colspan="1" valign="top">
				{$smarty.const.STRING_SUM}
			</td>
			<td colspan="5" align="right">
				<table align="right">
				{foreach from=$TotalPaymentsAmount key=_key item=_total}
					<tr><td align="right">{$_total|string_format:"%.2f"}</td><td>{$_key}</td></tr>
				{/foreach}
				</table>
			</td>
		</tr>
	</table>
{elseif $show_tables}
	<br /><br />{$smarty.const.AFFP_MSG_NOPAYMENTS_FOUND}
{/if}{* if $PaymentsNumber and $show_tables *}

{if $PaymentsNumber and $CommissionsNumber and $show_tables}
	<hr />
	{* balance *}
	<table width="100%" border="0" cellpadding="5" cellspacing="1" bgcolor="#56AFD6">
		<tr>
			<td valign="top">
			{$smarty.const.AFFP_USER_BALANCE}
			</td>
			<td align="right">
				<table align="right">
				{foreach from=$CurrencyISO3 item=_currency}
				{if $TotalCommissionsAmount[$_currency.currency_iso_3] or $TotalPaymentsAmount[$_currency.currency_iso_3]}
					<tr>
						<td align="right">
						{"`$TotalCommissionsAmount[$_currency.currency_iso_3]-$TotalPaymentsAmount[$_currency.currency_iso_3]`"|string_format:"%.2f"}
						</td>
						<td>
						{$_currency.currency_iso_3}
						</td>
					</tr>
				{/if}
				{/foreach}
				</table>
			</td>
		</tr>
	</table>
{/if}{* if $PaymentsNumber and $CommissionsNumber and $show_tables *}

<br />
</td>
</tr>
</table>